<template>
	<view class="content">
		<view class="status_bar"></view>
		<view class="tou">
			<!-- <view class="setting" @click="gopage('/pages/newpages/info')">
				<image src="../static/mine/shezhi.png" mode=""></image>
			</view> -->
			
			<view class="userbox" style="margin-top: 20upx;">
				<view class="headerview" style="margin-top: 0upx;">
					<image :src="baseURL+userData.avatar" mode="" class="header"></image>
					
				</view>
				<view class="uersinfo" style="margin-left: 20upx;">
					<view class="name" style="font-size: 28upx;">{{userData.NAME}}</view>
					<view class="company" style="font-size: 22upx;color: #eaeaea;">{{companyName}}</view>
					<view class="phone" style="font-size: 22upx;color: #eaeaea;">{{userData.PHONE}}</view>
					<!-- <view class="vip">
						<view class="fxian">风险等级：{{CompanyPoint}}分</view>
						<view class="vipdj">会员等级：Vip{{userData.vip_status}}</view>
					</view> -->
					<view class="righttop" style="position: relative;top:-120upx;left:400upx">
						<text style="background: #fff;padding:0 10upx 0 10upx;border-radius: 5upx;">设计师</text>
					</view>
					
					
				</view>
			</view>
			
			<view class="num-out" style="margin:0 auto">
				<view class="numbers">
					<view class="num-item">
						<view style="margin:20upx 0 0 50upx;">
							<view class="numtext">61分</view>
							<view class="numtext">风险等级</view>
						</view>
						
					</view>
					<view class="num-item">
						<view style="margin:20upx  0 0 0;">
							<view class="numtext">￥100</view>
							<view class="numtext">我的奖扣</view>
						</view>
					</view>
					<view class="num-item">
						<view style="margin:20upx  50upx 0 0;">
							<view class="numtext">61分</view>
							<view class="numtext">我的分数</view>
						</view>
					</view>
				</view>
			</view>
		</view>
		
		<view class="card">
			<view  class="weiTitle">
				<text>常用工具</text>
				<!-- <image src="../static/cut/20191123232532.png" mode="" style="margin-right: 40upx;"></image> -->
			</view>
			
			<view class="gj" style="margin-top: 50upx;padding: 0 50upx 0 60upx;">
				<view @click="gopage()" class="weiTitle-item">
					<image src="../static/mine/zuzhi.png" style="width: 80upx;height: 80upx;" mode=""></image>
					<text style="line-height: 80upx;margin-left: 30upx;">我的组织</text>
				</view>
				<view @click="gopage()" class="weiTitle-item">
					<image src="../static/mine/qiandao.png" style="width: 80upx;height: 80upx;" mode=""></image>
					<text style="line-height: 80upx;margin-left: 30upx;">我的签到</text>
				</view>
				<view @click="gopage()" class="weiTitle-item">
					<image src="../static/mine/shoucang.png" style="width: 80upx;height: 80upx;" mode=""></image>
					<text style="line-height: 80upx;margin-left: 30upx;">我的收藏</text>
				</view>
				<view @click="gopage()" class="weiTitle-item">
					<image src="../static/mine/fabu.png" style="width: 80upx;height: 80upx;" mode=""></image>
					<text style="line-height: 80upx;margin-left: 30upx;">我的发布</text>
				</view>

				<view @click="kefu()" class="weiTitle-item">
					<image src="../static/mine/zuanjia.png" style="width: 80upx;height: 80upx;" mode=""></image>
					<text style="line-height: 80upx;margin-left: 30upx;">我的专家</text>
				</view>
				<view @click="gopage()" class="weiTitle-item">
					<image src="../static/mine/kaohe.png" style="width: 80upx;height: 80upx;" mode=""></image>
					<text style="line-height: 80upx;margin-left: 30upx;">我的考核</text>
				</view>
				<view @click="gopage()" class="weiTitle-item">
					<image src="../static/mine/wendang.png" style="width: 80upx;height: 80upx;" mode=""></image>
					<text style="line-height: 80upx;margin-left: 30upx;">我的文档</text>
				</view>
				<view  @click="gopage('/pages/newpages/info')" class="weiTitle-item">
					<image src="../static/mine/shezhi.png" style="width: 50upx;height: 50upx;margin:15upx ;" mode=""></image>
					<text style="line-height: 80upx;margin-left: 30upx;">我的设置</text>
				</view>
			</view>
			
		</view>

		<!-- <view class="gongju">
			<view class="title">
				<text>常用工具</text>
				<view class="lookAll">查看全部 ></view>
			</view>
			<view class="list">
				<view class="li" @click="gopage('/pages/huihuandeweizhi/fengxianzhili')">
					<image src="../static/gerenzhongxin/13.png" mode=""></image>
					<view class="text">风险治理</view>
				</view>
				<view class="li">
					<image src="../static/gerenzhongxin/12.png" @click="scanCode" mode=""></image>
					<view class="text">扫一扫</view>
				</view>
				<view class="li" @click="scanCode2">
					<image src="../static/gerenzhongxin/11.png" mode=""></image>
					<view class="text">任务提醒</view>
				</view>
				<view class="li" @click="gopage('/pages/huihuandeweizhi/fengxianyujing')">
					<image src="../static/gerenzhongxin/10.png" mode=""></image>
					<view class="text">预警提醒</view>
				</view> 
				 <view class="li" @click="gopage('/pages/newpages/qiandao')">
					<image src="../static/gerenzhongxin/9.png" mode=""></image>
					<view class="text">签到</view>
				</view>
				<view class="li" @click="gopage('/pages/other/ExpertAdvice')">
					<image src="../static/gerenzhongxin/8.png" mode=""></image>
					<view class="text">专家</view>
				</view>
				<view class="li" @click="gopage('/pages/organization/index')">
					<image src="../static/gerenzhongxin/7.png" mode=""></image>
					<view class="text">组织</view>
				</view>
				<view class="li">
					<image src="../static/gerenzhongxin/6.png" mode=""></image>
					<view class="text">通知</view>
				</view>
				<view class="li">
					<image src="../static/gerenzhongxin/5.png" mode=""></image>
					<view class="text">文章下载</view>
				</view>
				<view class="li">
					<image src="../static/gerenzhongxin/4.png" mode=""></image>
					<view class="text">收藏</view>
				</view>
				<view class="li">
					<image src="../static/gerenzhongxin/3.png" mode=""></image>
					<view class="text">任务</view>
				</view>
				<view class="li">
					<image src="../static/gerenzhongxin/2.png" mode=""></image>
					<view class="text">扫一扫</view>
				</view>
				<view class="li" @click="gopage('/pages/riskEvaluation/riskLook')">
					<image src="../static/fengxianxuncha/risk_look.jpg" mode=""></image>
					<view class="text">风险巡查</view>
				</view>
				<view class="li" @click="gopage('/pages/riskEvaluation/riskAlarm')">
					<image src="../static/fengxianxuncha/alarm.png" mode=""></image>
					<view class="text">预警提醒</view>
				</view>
				<view class="li" @click="gopage('/pages/grid/index')">
					<image src="../static/img/risk/world.png" mode=""></image>
					<view class="text">网格责任</view>
				</view> 
				 <view class="li"></view> 
			  </view>
		</view> -->
	</view>
</template>
		
<script>
	export default {
		data() {
			return {
				CompanyPoint:0,
				companyName:'',
				userData:{},
				baseURL:this.$API.baseURL,
			}
		},
		onHide() {
			// #ifdef APP-PLUS
			/* 隐藏凸起图标 */
			var icon = plus.nativeObj.View.getViewById("icon");
			setTimeout(function() {
				if(icon){icon.hide();}
			}, 100);
			// #endif
		},
		onShow() {
			// #ifdef APP-PLUS
				var icon = plus.nativeObj.View.getViewById("icon");
				setTimeout(function() {
					if(icon){icon.show();}
				}, 100);
			// #endif
			
			uni.removeStorageSync('to_user');
			this.getCompanyPoint();
			this.getUserDetail();
		},
		methods: {
			//企业健康指数
			getCompanyPoint(){
				var _this = this;
				uni.request({
					url:this.$API.getCompanyPoint,
					method:"POST",
					data:{
						userid:uni.getStorageSync("userid"),
						company:uni.getStorageSync("company")
					},
					header:this.$API.get_head(),
					success: (res) => {
						_this.CompanyPoint = res.data.point;
						_this.companyName = res.data.companyName;
					},
					fail: () => {
						uni.showToast({
							title:"加载失败",
							icon:'none'
						})
					}
				})
			},
			//获取用户信息
			getUserDetail(){
				var _this=this;
				uni.request({
					url:this.$API.getUserDetail,
					method:"POST",
					data:{
						userid:uni.getStorageSync("userid"),
					},
					header:this.$API.get_head(),
					success: (res) => {
						_this.userData=res.data.data;
					},
					fail: () => {
						uni.showToast({
							title:"加载失败",
							icon:'none'
						})
					 }
				})
			},
			kefu(){
				uni.switchTab({
				    url: '/pages/other/kefu/kefu'
				});
			},
			gopage(url){
				// 判断是否为tabbar页面
				if(url == '/pages/other/ExpertAdvice'){
					uni.switchTab({url});
				}else{
					uni.navigateTo({url});
				}
			},
			//扫一扫
			scanCode(url){
				// #ifdef APP-PLUS
					/* 隐藏凸起图标 */
					var icon = plus.nativeObj.View.getViewById("icon");
					if(icon){icon.hide();}
				// #endif
				var _this = this;
				uni.scanCode({
				    success: function (res) {
						if(uni.getStorageSync("userid")){
							if(!_this.GetQueryString(res.result,'id')){
								return false;
							}
							uni.navigateTo({
								url:'/pages/huihuandeweizhi/fengxianxuncha?id='+_this.GetQueryString(res.result,'id')+'&position='+_this.GetQueryString(res.result,'position')
							})
						}else{
							plus.runtime.openURL(res.result)
						}
				    }
				});
			},
			//随手拍
			scanCode2(){
				// #ifdef APP-PLUS
					/* 隐藏凸起图标 */
					var icon = plus.nativeObj.View.getViewById("icon");
					if(icon){icon.hide();}
				// #endif
				// uni.scanCode({
				    // success: function (res) {
						// res.result = JSON.parse(res.result)
						uni.navigateTo({
							// url:'/pages/huihuandeweizhi/yinghuanshangchuan?id='+res.result.id+'&position = '+ res.result.position
							// url:'/pages/huihuandeweizhi/yinghuanshangchuan',
							url:'/pages/companyYujing/list'
						})
				    // }
				// });
			},
			//获取地址参数
			GetQueryString(url,name) { 
			  var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
			  url = url.slice(url.indexOf("?"));
			  var r = url.substr(1).match(reg); //获取url中"?"符后的字符串并正则匹配
			  var context = ""; 
			  if (r != null) 
				 context = r[2]; 
			  reg = null; 
			  r = null; 
			  return context == null || context == "" || context == "undefined" ? "" : context; 
			},
			// 微信授权登录对象
			// var aweixin=null;
			// 当前环境支持的所有授权登录对象
			// var auths = {};
			// 获取登录授权认证服务列表，单独保存微信登录授权对象
			// 5+APP在plusready事件中调用，uni-app在vue页面的onLoad中调用
			getService(){
				var _this = this;
				plus.oauth.getServices(function(services){
					for(var i in services){
						auths[services[i].id]=services[i] ;
					}
					aweixin = auths['weixin'];
					console.log(JSON.stringify(services))
					console.log(JSON.stringify(auths))
					_this.authLogout(aweixin)
				}, function(e){
					plus.nativeUI.alert("获取登录授权服务列表失败："+JSON.stringify(e));
				} );
			},
			// 注销登录认证
			authLogout(provider){
				if(!provider){
					plus.nativeUI.alert("当前环境不支持微信登录");
					return;
				}
				provider.logout(function(e){
					plus.nativeUI.alert("注销登录认证成功!");
				}, function(e){
					console.log(JSON.stringify(e))
					plus.nativeUI.alert("注销登录认证失败: "+JSON.stringify(e));
				});
			},
		}
	}
	
</script>

<style>
	.num-out{
		/* padding: 0 100upx 0 100upx; */
	}
	.numbers{
		position: relative;
		top:-30upx;
		width: 100%;
		display: flex;
		justify-content: space-between;
		background: rgb(237,243,255);
		border-radius: 30upx 30upx 0 0;
		/* padding: 0 10% 0 10%; */
	}
	.num-item{
		width: 25%;
		height: 125upx;
		/* border: 1upx solid #008000; */
	}
	.numtext{
		text-align: center; color: rgb(91,140,252);
	}
	.weiTitle-item{
		display: flex;
		height: 80upx;
		
		/* border-top: 1upx solid #edf3ff; */
		/* border-bottom: 1upx solid #e2e2e2; */
		border-top: 1upx solid #e2e2e2;
		width: 100%;
	}
	.weiTitle{
		padding: 24upx 0 0 50upx;
		width: 100%;
		box-sizing: border-box;
		}
	.weiTitle.fixed{
		position: fixed;top: var(--status-bar-height);
		left: 0;
		z-index: 9999;
		background: #fff;
		padding:20upx 24upx;
		-webkit-animation: toFixed 0.2s;
		-moz-animation: toFixed 0.2s;
		-o-animation: toFixed 0.2s;
		-webkit-animation: toFixed 0.2s;
		}
	.weiTitle text{
		color: #000000;
		font-size:36upx;
		padding-left: 20upx;
		border-left:12upx solid 
		#2892ff;font-weight:bold;
		}
	.weiTitle image{width: 12upx;height:24upx;float: right;margin-top:22upx;}
	
	
	
	
	.status_bar {
		position: fixed;
		top: 0;
		width:100%;
		height: var(--status-bar-height);
		width: 100%;
		background: #2b97fc;
	}
	
	.gongju{
		margin:0 20upx;
		box-shadow:0 0 10upx 4upx #d8d8d8;
		border-radius:10upx;
		padding:33upx 27upx 60upx;
		margin-top:40upx;
		margin-bottom:40upx;
		background:#FFFFFF;
	}
	.title{
		font-size:28upx;
		color:#333333;
		display:flex;
		align-items: center;
		padding-bottom:28upx;
		border-bottom: 1upx solid #e2e2e2;
	}
	.lookAll{
		margin-left:auto;
		color:#999999;
		font-size:26upx;
	}
	.list{
		display: flex;
		flex-flow: wrap;
		justify-content: space-between;
	}
	.li{
		width:25%;
		margin-top:50upx;
		text-align: center;
	}
	.li image{
		display:inline-block;
		margin:0 auto;
		max-width:70upx;
		max-height:70upx;
	}
	.li .text{
		font-size:26upx;
		color:#1a1a1a;
	}
	
	
	
	
	
	
	.tou{
		height:320upx;
		
		margin:var(--status-bar-height) 20rpx 0 20rpx;
		background:url(../static/mine/bg.png);
		border-radius:0 0 10upx 10upx;
		padding: 30upx;
		box-shadow:0 15upx 10upx 4upx #d8d8d8;
		background-repeat:no-repeat ;
		
		background-size: 100% 100%;
	}
	
	
	.setting{
		display: flex;
		justify-content: flex-end;
		margin-bottom:25upx;
		padding-top: 20px;
	}
	.setting image{
		height: 32upx;
		width:32upx;
	}
	.userbox{
		display: flex;
		padding: 30upx 0;
	}
	.headerview{
		width: 120upx;
		height: 120upx; 
		border-radius: 50%;
		background: #FFF;
		border: 3upx solid #27d9f4;
		padding: 3upx;
		
	}
	.header{
		width: 114upx;
		height: 114upx;
		min-width: 114upx;
		min-height: 114upx;
		margin-left:3upx;
		border-radius:50%;
	}
	.uersinfo{
		width:100%;
		position:relative;
	}
	.name{
		max-width:80%;
		overflow: hidden;
		white-space: nowrap;
		text-overflow: ellipsis;
		font-size:28upx;
		color:#FFFFFF;
	}
	.phone{
		max-width:80%;
		overflow: hidden;
		white-space: nowrap;
		text-overflow: ellipsis;
		font-size:28upx;
		color:#FFFFFF;
	}
	.vip{
		position:absolute;
		top: -20upx;
		right: -79upx;
		background:rgba(0,0,0,.4);
		padding:25upx;
		border-radius:25upx 0 0 25upx;
	}
	.fxian{
		color:#FFFFFF;
		margin-bottom: 15upx;
		font-size:22upx;
		white-space: nowrap;
	}
	.vipdj{
		color:#FFFFFF;
		font-size:22upx;
		white-space: nowrap;
	}
</style>